package com.es.www.kyl.filter;

import cn.hutool.core.util.CharsetUtil;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.es.www.kyl.bean.R;
import org.springframework.http.HttpStatus;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author by michangtao
 * @Date 2023/3/21 20:44
 * @Description
 */
public class BaseFilter {

    public static void errorResponse(HttpServletResponse response, R r) throws IOException {
        response.setStatus(HttpStatus.OK.value());
        response.setCharacterEncoding(CharsetUtil.UTF_8);
        response.setHeader("Content-Type", "application/json;charset=UTF-8");
        response.getWriter().println(JSONObject.toJSONString(r, SerializerFeature.WriteMapNullValue));
    }
}
